


<link rel="stylesheet" type="text/css" href="public/home/css/product.css">




<!-- 中间 -->
<div class="brand">
    <div class="brand-left fl">
            <div class="brand-l-top">
                    <h3 class="brand-title">产品世界</h3> 
                    <ul class="brand-list">
                            <li><a href="#">冲锋衣</a></li>
                            <li><a href="#">睡袋</a></li>
                            <li><a href="#">背包</a></li>
                            <li><a href="#">帐篷</a></li>
                    </ul>     
            </div>
            <div class="brand-l-mid"></div>
            <div class="brand-l-bottom1"></div>
            <ul class="brand-l-bottom2">
                    <li>名  称：户外运动装备有限公司</li>
                    <li>地  址：北京市石景山区苹果园路</li>
                    <li>电  话：010-8348495911</li>
                    <li>传  真：010-8348495912</li>
                    <li>联系人：陈先生</li>
                    <li>邮  编：100049</li>
                    <li>Email： moban@163.com</li>
                    <li>网  址： www.moban.com</li>
            </ul>
            <div class="brand-l-bottom3"></div>

    </div>


    <div class="brand-right fr">
            <div class="brand-r-title">
                    <h3 class="r-title-js">产品世界</h3>
                    <h3 class="r-title-nav">当前位置：<a>首页</a> > <a>产品世界</a> > <a>冲锋衣</a> </h3>       
            </div>
            <div class="brand-r-content">
                    <input type="hidden" name="id" value="<?php echo $date['id']?>">
                    <h1 class="goods-title"><?php echo $date['goods_name']?></h1>
                    <div class="goods">
                            <div class="goods-img fl">
                                    <a class="big">
                                            <img src="<?php echo $date['orignalimg']?>">
                                    </a> 
                                    <h3 class="small">
                                    <a href="##">
                                    <img class="sm" src="<?php echo $date['thumbimg']?>">
                                    </a>
                                    <?php foreach($img as $k=>$v):?>
                                    <a href="##">
                                            <img class="sm" src="<?php echo $v['thumb_img']?>">
                                    </a>
                                    <?php endforeach;?>
                                    </h3>     
                            </div> 

                            <ul class="goods-ms fl">
                                    <li><span>产品名称</span><b><?php echo $date['goods_name']?></b></li>
                                    <li><span>参考价格</span>￥<b class="price"><?php echo $date['price']?></b></li>
                                    <?php foreach($attr as $k=>$v):?>

                                    <?php if($v[0]['attr_type']==0):?>
                                    <li><span><?php echo $v[0]['attr_name'] ?></span>
                                        <select name="goodsattr" style="width:60px;">
                                              <?php foreach($v as $k1=>$v1):?>
                                              <option value="<?php echo $v1['id'];?>"><?php echo $v1['attr_value'];?></option>
                                              <?php endforeach;?>
                                        </select>
                                    </li>
                                    <?php else:?>
                                    <li><span><?php echo $v[0]['attr_name'] ?></span><b><?php echo $v[0]['attr_value']?></b>
                                    </li>
                                    <?php endif;?>

                                    <?php endforeach;?>
                                    <li><span>库存</span><b class="kc"></b></li>
                                    <li><input type="submit" value="加入购物车"></li>
                            </ul>
                            <div class="clear"></div>    
                    </div>

                    <div class="goods-js">
                            <h3><span></span><b>详细描述</b><div class="clear"></div></h3>
                            <ul>
                                    <?php foreach($otherattr as $k=>$v):?>
                                    <li><?php echo $v['attr_name']?>：<?php echo $v['attr_value']?></li>
                                    <?php endforeach;?>
                                    <li><?php echo $date['des']?></li>
                            </ul>
                    </div>
            </div>

    </div>


   
</div>


<!-- 中间 -->
<div class="clear"></div>
<script type="text/javascript">
$(function(){
    $('.sm').click(function(){
        var src=$(this).attr('src');
        var src1=src.replace('thumb_','');
        $('.big img').attr('src',src1);
    });
    
    var old_total=Number($('.price').text());
    $('select[name=goodsattr]').change(function(){
        //获得当前单选组合后的库存
        var arr=new Array();
        $('select[name=goodsattr]').each(function(i){
            arr[i]=$(this).val();
        });
        var goods_id=$('input[name=id]').val();

        $.ajax({
            type:'get',
            url:'index.php?c=product&a=show&id='+goods_id,
            data:{goodsattr_id:arr},
            dataType:'json',
            success:function(res){
                 if(res!=''){
                       $('.kc').text(res.number);
                       var new_total=old_total+Number(res.price);
                       $('.price').text(new_total);

                 }
            }
        });

    });

    $('input[type=submit]').click(function(){
           if($('input[name=session_name]').val()==0){
                alert('请登录，再购物');
                return false;
           }else{
                alert(2);
           }
    });


})
</script>

